package cn.com.dcsgo.config;

import cn.com.dcsgo.api.fallback.CartClientFallbackFactory;
import cn.com.dcsgo.api.fallback.ItemClientFallbackFactory;
import feign.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
@Slf4j
@ConditionalOnClass(WebMvcConfigurationSupport.class)
public class DefaultFeignConfig {
    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.BASIC;
    }

    @Bean
    public ItemClientFallbackFactory itemClientFallbackFactory(){
        log.info("初始化商品服务降级");
        return new ItemClientFallbackFactory();
    }

    @Bean
    public CartClientFallbackFactory cartClientFallbackFactory(){
        log.info("初始化购物车服务降级");
        return new CartClientFallbackFactory();
    }
}
